# -*- codeing = utf-8 -*-
# @Time : 2024/8/4 2:45
# @Author:北希
# @File :getCenterLeftData.py
# @Software: PyCharm
import json
import time
from .getPublicData import *

def getPieBrandData():
    cars = list(getAllCars())
    carVolume = {}
    for i in cars:
        if carVolume.get(i.brand,-1)== -1:
            carVolume[str(i.brand)] = int(i.saleVolume)
        else:
            carVolume[str(i.brand)] += int(i.saleVolume)

    carVolume = sorted(zip(carVolume.values(),carVolume.keys()),reverse=True)

    brandList = sorted(carVolume, reverse=True)[:10]
    sortDict = {i[1]: i[0] for i in brandList}
    lastPieList = []
    for k, v in sortDict.items():
        lastPieList.append({
            'name': k,
            'value': v
        })
    return lastPieList


